package GraphTheory;

import java.io.IOException;
import java.io.InputStreamReader;
import java.io.StreamTokenizer;
import java.util.Arrays;
import java.util.LinkedList;
import java.util.List;
import java.util.Queue;
import java.util.Scanner;

class Pair
{	public int x,y;
	public Pair(int X,int Y)
	{	x=X;y=Y;
	}
}
class Solver1008
{	int n,xO,yO,count=0;
	int[][] Map=new int[11][11];
	Queue<String> Lst=new LinkedList<String>();
	boolean n2c=false;
	
	public void Input() throws IOException
	{	int t1,t2;
		Scanner in=new Scanner(System.in);
		t1=in.nextInt();
		t2=in.nextInt();
		for (int i=0;i<=10;i++) Arrays.fill(Map[i],0);
		if (in.hasNextInt())
		{	n=t1;n2c=true;xO=t2;yO=in.nextInt();
			Map[xO][yO]=1;
			for (int i=2;i<=n;i++)
			{	t1=in.nextInt();
				t2=in.nextInt();
				Map[t1][t2]=1;
			}
		}
		else
		{	xO=t1;yO=t2;in.nextLine();
			while (true)
			{	String tmp=in.nextLine();
				Lst.add(tmp.substring(0,tmp.length()-1));
				if (tmp.charAt(tmp.length()-1)=='.') break;
			}
		}
	}
	private boolean Go(Pair p,int dx,int dy,Queue Q)
	{	if (p.x+dx>=1 && p.x+dx<=10 && p.y+dy>=1 && p.y+dy<=10)
			if (Map[p.x+dx][p.y+dy]==1)
			{	Q.add(new Pair(p.x+dx,p.y+dy));
				Map[p.x+dx][p.y+dy]=2;count++;
				return true;
			}
		return false;
	}
	private void Go(String fs,Queue Q,Pair p)
	{	for (int i=0;i<fs.length();i++)
			switch (fs.charAt(i))
			{	case 'R':	Q.add(new Pair(p.x+1,p.y));Map[p.x+1][p.y]=2;count++;break;
				case 'T':	Q.add(new Pair(p.x,p.y+1));Map[p.x][p.y+1]=2;count++;break;
				case 'L':	Q.add(new Pair(p.x-1,p.y));Map[p.x-1][p.y]=2;count++;break;
				case 'B':	Q.add(new Pair(p.x,p.y-1));Map[p.x][p.y-1]=2;count++;break;
			}
	}
	public void Solve() throws IOException
	{	Input();
		if (n2c)
		{	Queue<Pair> Q=new LinkedList<Pair>();
			System.out.println(xO+" "+yO);
			Q.add(new Pair(xO,yO));Map[xO][yO]=2;count++;
			while (!Q.isEmpty())
			{	String rs="";
				Pair p=Q.remove();
				rs+=Go(p,1,0,Q)?"R":"";
				rs+=Go(p,0,1,Q)?"T":"";
				rs+=Go(p,-1,0,Q)?"L":"";
				rs+=Go(p,0,-1,Q)?"B":"";
				rs+=(count==n && Q.size()==0)?".":",";
				System.out.println(rs);
			}
		}
		else
		{	Queue<Pair> Q=new LinkedList<Pair>();
			Q.add(new Pair(xO,yO));Map[xO][yO]=2;count++;
			while (!Lst.isEmpty())
			{	String fs=Lst.remove();
				Pair p=Q.remove();
				Go(fs,Q,p);
			}
			System.out.println(count);
			for (int i=1;i<=10;i++)
				for (int j=1;j<=10;j++)
					if (Map[i][j]==2)
						System.out.println(i+" "+j);
		}
	}
}
public class P1008
{	public static void main(String[] args) throws IOException
	{	Solver1008 solver=new Solver1008();
		solver.Solve();
	}
}
